<?
class indexController extends inabuurt_controller_action{

	
	public function indexAction(){
		require_once('./application/models/lessenModel.php');
		
		$this -> view -> setTpl('lessen.php');

				$model = lessenModel::getInstance($this -> conn);

		
			$itemsPerPage =30;
			
			
		$total = $model -> getAantal();
		
		$pages = ceil($total / $itemsPerPage);
		
		
		if($this -> request -> getParam(0) != NULL && $this -> request -> getParam(0) <= $pages && $this -> request -> getParam(0) > 0){
			
			$page = $this -> request -> getParam(0);
			
			
		}else{
			$page = 1;
		}
		
		if($page + 1 <= $pages){
		
		$this -> view -> nextPage = $page + 1;
		}
		
		if($page - 1 > 0){
		$this -> view -> prevPage = $page - 1;
		}
		
		
		$lessen = $model -> getAllLessen(($page * $itemsPerPage) - $itemsPerPage, $itemsPerPage);
		
		
		
		

		$this -> view -> lessen = $lessen;
		
		$this -> view -> render();
	}
		
		
}


?>